package bbs.controller;

import bbs.annotation.GlobalInterceptor;
import bbs.annotation.VerifyParam;
import bbs.controller.base.ABaseController;
import bbs.entity.query.UserInfoQuery;
import bbs.entity.vo.ResponseVO;
import bbs.service.UserInfoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController()
@RequestMapping({"/ucenter"})
public class UserInfoController extends ABaseController {

    @Resource
    private UserInfoService userInfoService;

    @RequestMapping({"/loadUserList"})
    public ResponseVO loadUserList(UserInfoQuery userInfoQuery) {
        return getSuccessResponseVO(userInfoService.findListByPage(userInfoQuery));
    }

    @RequestMapping({"/updateUserStatus"})
    @GlobalInterceptor(checkParams = true)
    public ResponseVO updateUserStatus(@VerifyParam(required = true) Integer status,
                                   @VerifyParam(required = true) String userId)
    {
        userInfoService.updateUserStatus(status, userId);
        return getSuccessResponseVO(null);
    }

    @RequestMapping({"/sendMessage"})
    @GlobalInterceptor(checkParams = true)
    public ResponseVO sendMessage(@VerifyParam(required = true) String message,
                                  @VerifyParam(required = true) String userId,
                                  @VerifyParam(required = true) Integer integral)
    {
        userInfoService.sendMessage(message, userId, integral);
        return getSuccessResponseVO(null);
    }
}